package com.ruoyi.common.message;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

/**
 * @author liliangyu
 */
@Data
public class WebSocketMessage {
    private String type;

    private String message;

    /**
     * 发送成功消息
     *
     * @param message
     * @return
     */
    public static WebSocketMessage success(final String template, final Object... message) {
        final WebSocketMessage webSocketMessage = new WebSocketMessage();
        webSocketMessage.setType("success");
        webSocketMessage.setMessage(StrUtil.format(template, message));
        return webSocketMessage;
    }

    /**
     * 发送错误消息
     *
     * @param message
     * @return
     */
    public static WebSocketMessage error(final String template, final Object... message) {
        final WebSocketMessage webSocketMessage = new WebSocketMessage();
        webSocketMessage.setType("error");
        webSocketMessage.setMessage(StrUtil.format(template, message));
        return webSocketMessage;
    }


}
